home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
187_01
/
center.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-12-28
|
951b
|
34 lines
#include "stdio.h"
/*@*****************************************************/
/*@ */
/*@ center - center a given string on a given length.*/
/*@ Trims trailing blanks before centering. */
/*@ */
/*@ Usage: center(string, length); */
/*@ NOTE: The string is output to STDOUT. */
/*@ */
/*@*****************************************************/
center(line, linlen)
int linlen;
char *line;
{
char *cp, *wp;
int countr, len;
char c;
len = strlen(trim(line)); /* get non-blank length */
/* output leading blanks */
for (countr=1; countr < (linlen - len)/2; countr++)
putc(' ', stdout);
/* output non-blank chars */
while (c = *cp++)
putc(c, stdout);
putc('\n', stdout); /* end of record */
}